package com.dingwen.treasure.kettle.base.vo;

import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.http.HttpStatus;
import cn.hutool.json.JSONUtil;
import lombok.*;

import java.io.Serializable;
import java.time.LocalDateTime;


/**
 * 结果
 *
 * @author dingwen
 * @date 2021/05/28
 * @since 1.0.0-SNAPSHOT
 */
@Builder
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> implements Serializable {

    private static final long serialVersionUID = -5399051578054163779L;

    /**
     * 代码,默认值200 ok。
     */
    @Builder.Default
    private int code = HttpStatus.HTTP_OK;

    /**
     * 消息,默认显示成功
     */
    @Builder.Default
    private String message = "SUCCESS";

    /**
     * 数据，默认为null
     */
    @Builder.Default
    private T data = null;


    /**
     * 当前时间,默认显示当前时间
     */
    @Builder.Default
    private String currentTime = LocalDateTimeUtil.formatNormal(LocalDateTime.now());


    @Override
    public String toString() {
        return JSONUtil.toJsonPrettyStr(this);
    }


}